﻿/*
* 
*
* 功 能： N/A
* 类 名： BDVALUE
*
* Ver    变更日期             负责人  变更内容
* ───────────────────────────────────
* 
*/
using System;
using System.Data;
using System.Collections.Generic;
using Maticsoft.Common;
using DQYT.HTDZ.Model;
using Best.Framework.DALFactory;
using DQYT.HTDZ.IDAL;
namespace DQYT.HTDZ.BLL
{
	/// <summary>
	/// 特征值数据表采集数据的基础上转换后得到的数据
	/// </summary>
	public partial class BDVALUEBLL
	{
		private readonly IBDVALUE dal=DataAccess.CreateBDVALUE();
		public BDVALUEBLL()
		{}
		#region  BasicMethod
		/// <summary>
		/// 是否存在该记录
		/// </summary>
		public bool Exists(decimal ID)
		{
			return dal.Exists(ID);
		}

		/// <summary>
		/// 增加一条数据
		/// </summary>
		public bool Add(BDVALUEModel model)
		{
			return dal.Add(model);
		}

		/// <summary>
		/// 更新一条数据
		/// </summary>
        public bool Update(BDVALUEModel model)
		{
			return dal.Update(model);
		}

		/// <summary>
		/// 删除一条数据
		/// </summary>
		public bool Delete(decimal ID)
		{
			
			return dal.Delete(ID);
		}
		/// <summary>
		/// 删除一条数据
		/// </summary>
		public bool DeleteList(string IDlist )
		{
			return dal.DeleteList(IDlist );
		}

		/// <summary>
		/// 得到一个对象实体
		/// </summary>
        public BDVALUEModel GetModel(decimal ID)
		{
			
			return dal.GetModel(ID);
		}

		/// <summary>
		/// 得到一个对象实体，从缓存中
		/// </summary>
        public BDVALUEModel GetModelByCache(decimal ID)
		{
			
			string CacheKey = "BDVALUEModel-" + ID;
			object objModel = Maticsoft.Common.DataCache.GetCache(CacheKey);
			if (objModel == null)
			{
				try
				{
					objModel = dal.GetModel(ID);
					if (objModel != null)
					{
						int ModelCache = Maticsoft.Common.ConfigHelper.GetConfigInt("ModelCache");
						Maticsoft.Common.DataCache.SetCache(CacheKey, objModel, DateTime.Now.AddMinutes(ModelCache), TimeSpan.Zero);
					}
				}
				catch{}
			}
            return (BDVALUEModel)objModel;
		}

		/// <summary>
		/// 获得数据列表
		/// </summary>
		public DataSet GetList(string strWhere)
		{
			return dal.GetList(strWhere);
		}
		/// <summary>
		/// 获得数据列表
		/// </summary>
        public List<BDVALUEModel> GetModelList(string strWhere)
		{
			DataSet ds = dal.GetList(strWhere);
			return DataTableToList(ds.Tables[0]);
		}
		/// <summary>
		/// 获得数据列表
		/// </summary>
        public List<BDVALUEModel> DataTableToList(DataTable dt)
		{
            List<BDVALUEModel> modelList = new List<BDVALUEModel>();
			int rowsCount = dt.Rows.Count;
			if (rowsCount > 0)
			{
                BDVALUEModel model;
				for (int n = 0; n < rowsCount; n++)
				{
					model = dal.DataRowToModel(dt.Rows[n]);
					if (model != null)
					{
						modelList.Add(model);
					}
				}
			}
			return modelList;
		}

		/// <summary>
		/// 获得数据列表
		/// </summary>
		public DataSet GetAllList()
		{
			return GetList("");
		}
        /// <summary>
        /// 通过用户自定义SQL语句获得数据列表
        /// </summary>
        public DataSet GetList_SQL(string strSql)
        {
            return dal.GetList_SQL(strSql);
        }

		/// <summary>
		/// 分页获取数据列表
		/// </summary>
		public int GetRecordCount(string strWhere)
		{
			return dal.GetRecordCount(strWhere);
		}
		/// <summary>
		/// 分页获取数据列表
		/// </summary>
		public DataSet GetListByPage(string strWhere, string orderby, int startIndex, int endIndex)
		{
			return dal.GetListByPage( strWhere,  orderby,  startIndex,  endIndex);
		}
		/// <summary>
		/// 分页获取数据列表
		/// </summary>
		//public DataSet GetList(int PageSize,int PageIndex,string strWhere)
		//{
			//return dal.GetList(PageSize,PageIndex,strWhere);
		//}
        /// <summary>
        /// 采用事务更新表数据
        /// </summary>
        /// <param name="dt">表数据</param>
        /// <param name="TableName">表名称</param>
        /// <returns></returns>
        public bool TransUpdateTable(DataTable dt)
        {
            return dal.TransUpdateTable(dt);
        }

		#endregion  BasicMethod
		#region  ExtensionMethod

		#endregion  ExtensionMethod
	}
}

